<template>
  <div>
    <a-divider orientation='left'>采购记录</a-divider>
    <f-table ref='table1' rowKey='detailsId' :showSetting='false' :showPagination='false' :tableColumns='columns1'  :scroll='{y:300}' :multiple='false'  :operator='operator' :autoLoad='false' :params='queryParam' :api='api.erpSearch.selectStockList' >
         <span slot='orderNo' slot-scope='text, record, index'>
            <span v-clipboard:copy='text' v-clipboard:success='onCopy' style='cursor:pointer'>{{ text }}</span>
        </span>
    </f-table>
    <a-divider orientation='left'>销售历史</a-divider>
    <f-table ref='table' rowKey='detailsId' :showSetting='false' :showPagination='false' :tableColumns='columns'  :scroll='{y:300}' :multiple='false'  :operator='operator' :autoLoad='false' :params='queryParam' :api='api.erpSearch.selectSaleHistoryList'>
         <span slot='orderNo' slot-scope='text, record, index'>
            <span v-clipboard:copy='text' v-clipboard:success='onCopy' style='cursor:pointer'>{{ text }}</span>
        </span>
    </f-table>
  </div>
</template>
<script>
import api from "./../../js/api"

export default {
  name: "SaleHistory",
  components: {},
  data() {
    let me = this
    //操作按钮
    let operator = []
    let customFlag = this.$store.state.user.customFlag
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {
        companyId: this.$store.state.user.companyId
      },
      tableObj: null,
      superAdmin: this.superAdmin,
      // 表头
      columns: [
        {
          title: '#',
          width: '70px',
          align: 'center',
          customRender: (text, record, index) => index + 1
        },
        {
          title: '单据日期',
          width: '120px',
          dataIndex: 'orderDate'
        },
        {
          title: '订单编号',
          width: '120px',
          dataIndex: 'orderNo'
        },
        {
          title: '单位名称',
          align: 'left',
          width: '180px',
          dataIndex: 'customName'
        },
        {
          title: '部门名称',
          align: 'left',
          width: '80px',
          dataIndex: 'deptName'
        },
        {
          title: '业务员',
          align: 'left',
          width: '80px',
          dataIndex: 'saleManName'
        },
        {
          title: '批号',
          align: 'left',
          width: '70px',
          dataIndex: 'lotNo'
        },
        {
          title: '数量',
          align: 'left',
          width: '70px',
          dataIndex: 'saleNum'
        },
        {
          title: '成本单价',
          align: 'left',
          width: '70px',
          dataIndex: 'costPrice'
        }
      ],
      // 表头
      columns1: [
        {
          title: '#',
          width: '70px',
          align: 'center',
          customRender: (text, record, index) => index + 1
        },
        {
          title: '仓库编码',
          align: 'left',
          width: '70px',
          dataIndex: 'storeCode'
        },
        {
          title: '采购日期',
          width: '120px',
          dataIndex: 'stockDate'
        },
        {
          title: '批号',
          align: 'left',
          width: '120px',
          dataIndex: 'lotNo'
        },
        {
          title: '数量',
          align: 'left',
          width: '80px',
          dataIndex: 'saleNum'
        },
        {
          title: '成本单价',
          align: 'left',
          width: '80px',
          dataIndex: 'costPrice'
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  mounted() {
    this.tableObj = this.$refs.table
  },
  methods: {
    onCopy() {
      this.$message.success("复制成功!")
    },
    setData(data) {
      if (data && data.orderNo) {
        this.queryParam.drugNo = data.drugNo
        this.queryParam.lotNo = data.ph
        this.queryParam.storeCode = data.storeCode
        this.$refs["table"].refresh(false)
        this.$refs["table1"].refresh(false)
      }
    }
  }
}
</script>
